﻿<phoneNavigation:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Navigation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Phone7ActionPack_Controls="clr-namespace:Phone7ActionPack.Controls;assembly=Phone7ActionPack" 
    xmlns:Phone7ActionPack_ValueConverters="clr-namespace:Phone7ActionPack.ValueConverters;assembly=Phone7ActionPack" 
    x:Class="P7AP.Samples.LocationControl.MainPage"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    >
    <phoneNavigation:PhoneApplicationPage.Resources>
        <Phone7ActionPack_ValueConverters:TimeAgoValueConverter x:Key="TimeAgoValueConverter"/>
        <Phone7ActionPack_ValueConverters:DDtoDMSValueConverter x:Key="DDtoDMSValueConverter1"/>
        <Phone7ActionPack_ValueConverters:DDtoDMSValueConverter x:Key="DDtoDMSValueConverter"/>
        <DataTemplate x:Key="PastLocations">
            <Grid d:DesignWidth="285" d:DesignHeight="51">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="144"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <TextBlock x:Name="LocationTime" TextWrapping="Wrap" Text="{Binding Timestamp.LocalDateTime, Converter={StaticResource TimeAgoValueConverter}}" />
                <StackPanel Grid.Column="1" d:LayoutOverrides="Width" Orientation="Horizontal">
                    <TextBlock x:Name="Latitude" TextWrapping="Wrap" Text="{Binding Location.Latitude, ConverterParameter=latitude, Converter={StaticResource DDtoDMSValueConverter}}"/>
                    <TextBlock TextWrapping="Wrap" Text="," d:LayoutOverrides="Height" Margin="2,0,4,0"/>
                    <TextBlock x:Name="Longitude" TextWrapping="Wrap" Text="{Binding Location.Longitude, ConverterParameter=longitude, Converter={StaticResource DDtoDMSValueConverter1}}" Width="205"/>
                </StackPanel>
            </Grid>
        </DataTemplate>
    </phoneNavigation:PhoneApplicationPage.Resources>
    <phoneNavigation:PhoneApplicationPage.FontFamily>
        <StaticResource ResourceKey="PhoneFontFamilyNormal"/>
    </phoneNavigation:PhoneApplicationPage.FontFamily>
    <phoneNavigation:PhoneApplicationPage.FontSize>
        <StaticResource ResourceKey="PhoneFontSizeNormal"/>
    </phoneNavigation:PhoneApplicationPage.FontSize>
    <phoneNavigation:PhoneApplicationPage.Foreground>
        <StaticResource ResourceKey="PhoneForegroundBrush"/>
    </phoneNavigation:PhoneApplicationPage.Foreground>
    <Grid x:Name="LayoutRoot" Background="{StaticResource PhoneBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitleGrid is the name of the application and page title-->
        <Grid x:Name="TitleGrid" Grid.Row="0">
            <TextBlock Text="Location Control App" x:Name="textBlockPageTitle" Style="{StaticResource PhoneTextPageTitle1Style}"/>
            <TextBlock Text="Location Sample" x:Name="textBlockListTitle" Style="{StaticResource PhoneTextPageTitle2Style}" FontSize="64" Margin="0,43,0,0"/>
        </Grid>

        <Grid x:Name="ContentGrid" Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="100"/>
                <RowDefinition Height="0.362*"/>
                <RowDefinition Height="0.638*"/>
            </Grid.RowDefinitions>
            <Phone7ActionPack_Controls:LocationControl x:Name="LocationControl" VerticalAlignment="Top" Height="30"/>
            <ToggleButton x:Name="WatcherEnabled" Content="ToggleButton" HorizontalAlignment="Left" Height="4" Style="{StaticResource PhoneToggleSwitch}" Width="0" IsChecked="{Binding LocationWatcherEnabled, ElementName=LocationControl, Mode=TwoWay}"/>
            <TextBlock x:Name="WatcherEnabledLabel" HorizontalAlignment="Right" TextWrapping="Wrap" Text="Location Watcher Enabled" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Foreground="{StaticResource PhoneForegroundBrush}" Margin="0,34,34,29" d:LayoutOverrides="Height"/>
            <Grid Grid.Row="1" Margin="2">
                <Grid.RowDefinitions>
                    <RowDefinition Height="0.25*"/>
                    <RowDefinition Height="0.25*"/>
                    <RowDefinition Height="0.25*"/>
                    <RowDefinition Height="0.25*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="0.487*"/>
                    <ColumnDefinition Width="0.513*"/>
                </Grid.ColumnDefinitions>
                <TextBlock x:Name="LatitudeLabel" HorizontalAlignment="Right" TextWrapping="Wrap" Text="Latitude" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Foreground="{StaticResource PhoneForegroundBrush}" Margin="0,0,4,0"/>
                <TextBlock x:Name="Latitude" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Latitude, ElementName=LocationControl}" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Foreground="{StaticResource PhoneForegroundBrush}" Margin="4,0" Grid.Column="1"/>
                <TextBlock x:Name="LongitudeLabel" HorizontalAlignment="Right" TextWrapping="Wrap" Text="Longitude" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Foreground="{StaticResource PhoneForegroundBrush}" Grid.Row="1" Margin="0,0,4,0"/>
                <TextBlock x:Name="Longitude" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Longitude, ElementName=LocationControl}" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Foreground="{StaticResource PhoneForegroundBrush}" Margin="4,0,0,0" Grid.Column="1" Grid.Row="1"/>
                <TextBlock x:Name="VerticalAccuracyLabel" HorizontalAlignment="Right" TextWrapping="Wrap" Text="Vertical Accuracy" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Foreground="{StaticResource PhoneForegroundBrush}" Grid.Row="2" ToolTipService.ToolTip="Horizontal Accuracy" Margin="0,0,4,0"/>
                <TextBlock x:Name="VerticalAccuracy" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding VerticalAccuracy, ElementName=LocationControl}" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Foreground="{StaticResource PhoneForegroundBrush}" Margin="4,0,0,0" Grid.Column="1" Grid.Row="2"/>
                <TextBlock x:Name="HorizontalAccuracyLabel" HorizontalAlignment="Right" TextWrapping="Wrap" Text="Horizontal Accuracy" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Foreground="{StaticResource PhoneForegroundBrush}" Grid.Row="3" Margin="0,0,4,0"/>
                <TextBlock x:Name="HorizontalAccuracy" HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding HorizontalAccuracy, ElementName=LocationControl}" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeMediumLarge}" Foreground="{StaticResource PhoneForegroundBrush}" Margin="4,0,0,0" Grid.Column="1" Grid.Row="3"/>
            </Grid>
            <ItemsControl x:Name="LocationHistory" Grid.Row="2" ItemsSource="{Binding History, ElementName=LocationControl}" ItemTemplate="{StaticResource PastLocations}" Foreground="{StaticResource PhoneForegroundBrush}"/>
        </Grid>
    </Grid>

</phoneNavigation:PhoneApplicationPage>